package neuralmusic.brain.module;

import neuralmusic.brain.Global;

/**
 * Connects to a neuron with a given weight.
 */
public class Connection implements Excitable {

	public float weight = 1.0f;
	private Excitable sink;
	private Neuron src;
	

	public Connection(Neuron src,Excitable out, float weight){
	
		sink = out;
		this.src=src;
		this.weight = weight;

	}

	public Connection(float f) {
		this.weight=f;

	}

	public void excite(float val) throws BrainException {  // TODO rename excite 
		if (sink == null){
			Global.traceConnection("  SINK IS NULL ",this);	
			throw new BrainException(" SINK IS NULL ");
		}
		sink.excite(val * weight);
	}


	public void setSink(Excitable output) {
		assert(output!=null);
		sink=output;	
	}

	
	public Excitable getSink() {
		return sink;
	}

	public Neuron getSource() {
		return src;
	}

}
